import 'package:enterprise_v6_app/app/components/custom_modele/custom_card.dart';
import 'package:enterprise_v6_app/app/components/custom_modele/custom_row_title.dart';
import 'package:enterprise_v6_app/app/core/core.dart';
import 'package:enterprise_v6_app/app/modules/application/education/train_program/online_training/plan_info/plan_info_controller.dart';

///计划信息
class PlanInfoPage extends StatelessWidget {
  PlanInfoPage({super.key});

  final controller = Get.put(PlanInfoController());

  @override
  Widget build(BuildContext context) {
    return GetBuilder(
        init: controller,
        builder: (_) {
          return SingleChildScrollView(
            child: Container(
              padding: EdgeInsets.only(left: 16.w, top: 14.w, right: 16.w, bottom: 14.w),
              child: CustomCard(
                titleWidget: Column(
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: [
                    titleWidget(),
                  ],
                ),
                content: Column(
                  crossAxisAlignment: CrossAxisAlignment.end,
                  children: [
                    CustomRowTitle(
                      title: '培训类型：',
                      content: controller.data?.trainingTypeName ?? '',
                    ),
                    CustomRowTitle(
                      title: '培训方式：',
                      content: controller.data?.trainingMethodsName ?? '',
                    ),
                    CustomRowTitle(
                      title: '培训途径：',
                      content: controller.data?.trainingChannels == '1' ? '线上' : '线下',
                    ),
                    CustomRowTitle(
                      title: '培训学时：',
                      content: '${controller.data?.trainingHours ?? ''}',
                    ),
                    CustomRowTitle(
                      title: '培训级别：',
                      content: controller.data?.trainingLevelName ?? '',
                    ),
                    CustomRowTitle(
                      title: '培训开始日期：',
                      content: controller.data?.startTime ?? '',
                    ),
                    CustomRowTitle(
                      title: '培训结束日期：：',
                      content: controller.data?.endTime ?? '',
                    ),
                    CustomRowTitle(
                      title: '培训组织单位：',
                      content: controller.data?.organizationalUnitName ?? '',
                    ),
                    CustomRowTitle(
                      title: '培训地点：',
                      content: controller.data?.place ?? '',
                    ),
                    const CustomRowTitle(
                      title: '参加人员：',
                      content: '',
                    ),
                    AppGaps.vGap10,
                    Container(
                      margin: EdgeInsets.only(left: 65.w),
                      child: Wrap(
                        spacing: 47.w, // 主轴(水平)方向间距
                        runSpacing: 12.w, // 纵轴（垂直）方向间距
                        direction: Axis.horizontal,
                        // children: controller.sampleUserSign.map<Widget>((item) {
                        children: controller.getEducationPlanUsersList!.map<Widget>((user) {
                          return Text(
                            user.userName ?? '',
                            style: TextStyle(
                              color: const Color(0xFF495061),
                              fontWeight: FontWeight.w400,
                              fontSize: 14.sp,
                            ),
                          );
                        }).toList(),
                      ),
                    )
                  ],
                ),
              ),
            ),
          );
        });
  }

  Widget titleWidget() {
    return Row(
      children: [
        Container(
          height: 12.w,
          width: 3.w,
          decoration: BoxDecoration(
            color: Colors.blue,
            borderRadius: BorderRadius.circular(6.w),
          ),
        ),
        AppGaps.hGap10,
        Expanded(
            child: Text(
          '培训名称：${controller.data?.planName ?? ''}',
          style: TextStyle(
            fontSize: 16.sp,
            fontWeight: FontWeight.w500,
          ),
        )),
      ],
    );
  }
}
